package com.kg.fiber.service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.kg.fiber.service.pcie8622.Pcie8622;

@Component
//@Log4j
public class PciStarter {
	
	@Autowired
	private Pcie8622 pcie8622;
	
	@PostConstruct
	private void postConstruct() {
	}
	
	@PreDestroy
	private void preDestroy() {
	}
	
	
	@Scheduled(cron="0/5 * *  * * ? ")   
    public void doScheduled() {
		
		this.start();
    }
	
	private void start() {
		pcie8622.applyConfig();
		if(!isStarted()) pcie8622.start();
	}
	
	private boolean isStarted() {
		return pcie8622.isStarted();
	}
	
	public void runtime(StringBuilder sb) {
		pcie8622.runtime(sb);
	}

}
